{% extends "base_sub.html" %}

{% block title %}表单邮件{% endblock title %}

{% block content %}
<div id="formmail" class="new_win">
    <h1 id="win_title">{{ to_name }}向您发送邮件</h1>

    <form name="fformmail" action="/bbs/formmail_send" onsubmit="return fformmail_submit(this);" method="post" enctype="multipart/form-data" style="margin:0px;">
        <input type="hidden" name="token" value="">
        <input type="hidden" name="to" value="{{ to_email }}">
        <input type="hidden" name="attach" value="2">
        {% if member %}
        <input type="hidden" name="fnick" value="{{ member.mb_nick }}">
        <input type="hidden" name="fmail" value="{{ member.mb_email }}">
        {% endif %}

        <div class="form_01 new_win_con">
            <h2 class="blind">邮件写作</h2>
            <ul>
                {% if not member %}
                <li>
                    <label for="fnick" class="blind">姓名<strong>必不可少的</strong></label>
                    <input type="text" name="fnick" id="fnick" required class="frm_input full_input required" placeholder="姓名">
                </li>
                <li>
                    <label for="fmail" class="blind">E-mail<strong>必不可少的</strong></label>
                    <input type="text" name="fmail"  id="fmail" required class="frm_input full_input required email" placeholder="E-mail">
                </li>
                {% endif %}
                <li>
                    <label for="subject" class="blind">标题<strong>必不可少的</strong></label>
                    <input type="text" name="subject" id="subject" required class="frm_input full_input required"  placeholder="标题">
                </li>
                <li class="chk_box">
                    <span class="blind">格式</span>
                    <input type="radio" name="type" value="0" id="type_text" checked>
                    <label for="type_text"><span></span>TEXT</label>
                    
                    <input type="radio" name="type" value="1" id="type_html">
                    <label for="type_html"><span></span>HTML</label>
                    
                    <input type="radio" name="type" value="2" id="type_both">
                    <label for="type_both"><span></span>TEXT+HTML</label>
                </li>
                <li>
                    <label for="content" class="blind">内容<strong>必不可少的</strong></label>
                    <textarea name="content" id="content" required class="required"></textarea>
                </li>
                <li class="formmail_flie">
                    <div class="file_wr">
                        <label for="file1" class="lb_icon"><i class="fa fa-download" aria-hidden="true"></i><span class="blind"> 附件 1</span></label>
                        <input type="file" name="file1"  id="file1"  class="frm_file full_input">
                </div>
                <div class="frm_info">附件可能会丢失，因此请务必在发送邮件后检查文件是否已附加.</div>
                </li>
                <li class="formmail_flie">
                    <div class="file_wr">
                        <label for="file2" class="lb_icon"><i class="fa fa-download" aria-hidden="true"></i><span class="blind"> 附件 2</span></label>
                        <input type="file" name="file2" id="file2" class="frm_file full_input">
                    </div>
                </li>
                <li>
                    <span class="blind">自动注册预防</span>
                    <!-- Captcha Start -->
                    <fieldset id="captcha" class="captcha">
                        {% include captcha_widget(request) ignore missing %}
                    </fieldset>
                    <!-- Captcha End -->
                </li>
            </ul>
            <div class="win_btn">
                <button type="submit" id="btn_submit" class="btn_b02 reply_btn">已邮寄</button>
                <button type="button" onclick="window.close();" class="btn_close">窗口关闭</button>
            </div>
        </div>
    </form>
</div>

<script>
with (document.fformmail) {
    if (typeof fname != "undefined")
        fname.focus();
    else if (typeof subject != "undefined")
        subject.focus();
}

function fformmail_submit(f)
{

    if (f.file1.value || f.file2.value) {
        if (!confirm("如果附件容量很大，则传输需要很长时间.\n\n在发送邮件完成之前，不要关闭或刷新窗口."))
            return false;
    }

     // captcha 使用时
     if (typeof check_captcha === "function") {
        if (!check_captcha(f)) {
            return false;
        }
    }

    document.getElementById('btn_submit').disabled = true;

    return true;
}
</script>
{% endblock content %}